package com.ptu.mapper;

import com.github.pagehelper.Page;
import com.ptu.annotation.AutoFill;
import com.ptu.dto.StorePageQueryDTO;
import com.ptu.entity.Store;
import com.ptu.enumeration.OperationType;
import com.ptu.vo.StoreVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface StoreMapper {

    /**z
     * 根据用户名查询店铺
     * @param username
     * @return
     */
    @Select("select * from store where username = #{username}")
    Store getByUsername(String username);

    /**
     * 插入店铺数据
     * @param store
     */
    @Insert("insert into store (name, username, password, phone, sex, id_number, status, create_time, update_time, update_user, shopstatus) " +
            "values " +
            "(#{name}, #{username}, #{password}, #{phone}, #{sex}, #{idNumber}, #{status}, #{createTime}, #{updateTime}, #{updateUser}, #{shopstatus})")
    void insert(Store store);

    /**
     * 分页查询
     * @param storePageQueryDTO
     * @return
     */
    Page<Store> pageQuery(StorePageQueryDTO storePageQueryDTO);

    /**
     * 根据主键动态修改属性
     * @param store
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Store store);

    /**
     * 根据id查询员工
     * @param id
     * @return
     */
    @Select("select * from store where id = #{id}")
    StoreVO getById(Long id);
}
